<template>
  <view class="quotation-Info">
	  <!-- 公共组件-每个页面必须引入 -->
	  <public-module></public-module>
    <view class="quo-Info-top">
      <view style="text-align: center;margin: 10px 0;">
        <text>{{list.priceState | priceState}}</text>
      </view>
      <view class="info-top-cell">
        <u-cell-group>
          <u-cell title="询价商品" :value="list.inquiryTitle"></u-cell>
          <u-cell title="询价数量" :value="list.goodsNum+'吨'"></u-cell>
          <u-cell title="收货地区" :value='list.receiveArea'></u-cell>
          <u-cell title="收货日期" :value='list.receiveDate'></u-cell>
          <u-cell title="收货方式" :value='list.sendTypes'></u-cell>
          <u-cell title="结算方式" :value='list.payTypes'></u-cell>
          <u-cell title="询价时间" :value='list.inquiryTime'></u-cell>
        </u-cell-group>
      </view>
    </view>
    <view style="margin: 10px;">
      <text>我的报价</text>
    </view>
    <view class="quo-Info-middle">
      <view class="info-middle-cell">
        <u-cell-group>
          <u-cell title="报价" :value='list.purchasePrice'>
          </u-cell>
          <u-cell title="报价数量" :value="list.priceNum+'吨'">

          </u-cell>
          <u-cell title="货物所在地区" :value='list.sendArea'></u-cell>
          <u-cell title="交货日期" :value='list.sendDate'></u-cell>
          <u-cell title="交货方式" :value='list.priceSendTypes'></u-cell>
          <u-cell title="结算方式" :value='list.pricePayTypes'></u-cell>
          <u-cell title="报价时间" :value='list.priceTime'></u-cell>
        </u-cell-group>
      </view>
    </view>
    <view class="quo-Info-bottom" v-if="list.priceState == 0 || list.priceState == 10">
      <u-button type="error" shape="circle" @click="phoneInquiry">联系询价人</u-button>
      <u-button type="warning" shape="circle" @click.stop='changePriceOperate'>取消报价</u-button>
    </view>
  </view>
</template>

<script>
  import {
    priceDetail,
    priceOperate
  } from '@/config/api2.js'
  export default {
    data() {
      return {
        list: {}
      }
    },
    onLoad(e) {
      this.getPriceDetail(e.priceId)
    },
    methods: {
      getPriceDetail(priceId) {
        priceDetail({
          priceId
        }).then(res => {
          this.list = res
        })
      },
      changePriceOperate() {
        uni.showModal({
          title: '删除提示',
          content: '您将取消报价',
          success: (res) => {
            if (res.confirm) {
              priceOperate({
                priceId: this.list.priceId,
                operateType: 'cancel'
              }).then(res => {
                uni.navigateBack();
              })
            } else if (res.cancel) {
              console.log('用户点击取消');
            }
          }
        });

      },
      phoneInquiry() {
        uni.makePhoneCall({
          phoneNumber: this.list.inquiryPhone,
        })
      },
    }
  }
</script>

<style lang="scss">
  @import '@/style/wmj.scss';
  @import '@/style/common.scss';
</style>